<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
            "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>



<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="hevea 1.08">
<LINK rel="stylesheet" type="text/css" href="umsroot.css">
<TITLE>
Suspending Built-Ins and the Suspend-Library
</TITLE>
</HEAD>
<BODY >
<A HREF="umsroot106.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="umsroot104.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="umsroot108.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<HR>

<H2 CLASS="section"><A NAME="htoc235">17.3</A>&nbsp;&nbsp;Suspending Built-Ins and the Suspend-Library</H2>

Basic ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> has two built-in predicates whose behaviour includes
suspending: the sound negation built-in
<A HREF="../bips/kernel/control/T-1.html"><B>&sim;/1</B></A><A NAME="@default955"></A> and the sound disequality
predicate <A HREF="../bips/kernel/termcomp/TE-2.html"><B>&sim;=/2</B></A><A NAME="@default956"></A>.
Instead of succeeding or failing, they will suspend when their arguments
are insufficiently instantiated to make a decision. For example
<BLOCKQUOTE CLASS="quote"><PRE CLASS="verbatim">
?- X ~= 3.
X = X
There is 1 delayed goal.
Yes (0.00s cpu)
</PRE></BLOCKQUOTE>
Here, the system does not have enough information to decide whether the
query is true or false. The goal remains delayed and we have a case of
floundering
(the ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> toplevel indicates this situation by printing a message
about delayed goals at the end of the computation).<BR>
<BR>
However, when the variable which was responsible for the suspension gets instantiated
later, the delayed goal will be resumed (woken) and either succeed, fail, or
suspend again. In the following example, the disequality predicate initially
suspends, but wakes up later and succeeds or fails, respectively:
<BLOCKQUOTE CLASS="quote"><PRE CLASS="verbatim">
?- X ~= 3, X = 4.
X = 4
Yes (0.00s cpu)
?- X ~= 3, X = 3.
No (0.00s cpu)
</PRE></BLOCKQUOTE>
<A NAME="suspendsolver"></A>
Further predicate implementations with the same behaviour (delay until
all arguments are ground) can be found in the <B>suspend library</B>
<A NAME="@default957"></A>
<A HREF="../bips/lib/suspend/index.html"><B>lib(suspend)</B></A><A NAME="@default958"></A>.
In particular, it implements all common arithmetic predicates plus
the constraints defined by the Common Arithmetic Solver Interface
(see Constraint Library Manual), for instance
<PRE CLASS="verbatim">
=:=/2, =\=/2,  &gt;=/2,  =&lt;/2,  &gt;/2,  &lt;/2,
 $=/2, $\=/2, $&gt;=/2, $=&lt;/2, $&gt;/2, $&lt;/2,
 #=/2, #\=/2, #&gt;=/2, #=&lt;/2, #&gt;/2, #&lt;/2,
integers/1, reals/1,
</PRE>The solver will suspend these predicates until all their arguments
are ground<SUP><A NAME="text26" HREF="umsroot104.html#note26">1</A></SUP>.<BR>
<BR>
The suspend library is loaded into ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> on start-up, but the
constraints associated with the suspend solver are not imported.
To use them, either import the suspend library to the current module,
or call the constraint qualified with the module:
<BLOCKQUOTE CLASS="quote"><PRE CLASS="verbatim">
suspend:(X &gt; 2), suspend:(X #=&lt; 5)
</PRE></BLOCKQUOTE>
<HR>
<A HREF="umsroot106.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="umsroot104.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="umsroot108.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
</BODY>
</HTML>
